Skip to content

Avoid syncing native parent volume to AirPlay protocols#3980

Draft
jyundt wants to merge 2 commits into
music-assistant:devfrom
jyundt:airplay-native-parent-volume
Draft

Avoid syncing native parent volume to AirPlay protocols#3980
jyundt wants to merge 2 commits into
music-assistant:devfrom
jyundt:airplay-native-parent-volume

Conversation

@jyundt
Copy link
Copy Markdown

@jyundt jyundt commented May 25, 2026

What does this implement/fix?

Avoid copying a protocol-linked parent player's volume into an AirPlay protocol player when the parent has native volume control.

For native receivers/amplifiers, the parent volume represents device volume, while AirPlay/RAOP volume is stream/protocol volume. Some devices, including Yamaha MusicCast receivers, map those scales differently. Reusing the native parent volume as AirPlay startup volume can cause track changes to unexpectedly alter the receiver volume.

Related issue (if applicable):

Types of changes

  • Bugfix (non-breaking change which fixes an issue) — bugfix
  • New feature (non-breaking change which adds functionality) — new-feature
  • Enhancement to an existing feature — enhancement
  • New music/player/metadata/plugin provider — new-provider
  • Breaking change (fix or feature that would cause existing functionality to not work as expected) — breaking-change
  • Refactor (no behaviour change) — refactor
  • Documentation only — documentation
  • Maintenance / chore — maintenance
  • CI / workflow change — ci
  • Dependencies bump — dependencies

Testing

  • The code change is tested and works locally.
  • pre-commit run --all-files passes.
  • pytest passes, and tests have been added/updated under tests/ where applicable.
  • For changes to shared models, the companion PR in music-assistant/models is linked.
  • For changes affecting the UI, the companion PR in music-assistant/frontend is linked.
  • I have read and complied with the project's AI Policy for any AI-assisted contributions.

Verified with:

  • python3 -m py_compile music_assistant/providers/airplay/player.py tests/providers/airplay/test_player.py
  • git diff --check
  • Python 3.14 container: SKIP=no-commit-to-branch pre-commit run --files music_assistant/providers/airplay/player.py tests/providers/airplay/test_player.py
  • Python 3.14 container: pytest -o addopts="" tests/providers/airplay/test_player.py

MarvinSchenkel
MarvinSchenkel previously approved these changes May 25, 2026
Copy link
Copy Markdown
Contributor

@MarvinSchenkel MarvinSchenkel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Automated review (no CRITICAL/PROBLEM findings).

The guard in sync_volume_level cleanly addresses the bug: a parent with native volume control reports device/amplifier volume (different scale than AirPlay/RAOP protocol volume), so copying it onto the AirPlay protocol volume on each track change caused unexpected receiver volume changes on devices like Yamaha MusicCast. Docstring and inline comment explain the why, and the two new tests cover both branches.

Thanks @jyundt 🎉

@jyundt
Copy link
Copy Markdown
Author

jyundt commented May 25, 2026

I updated my PR message to include the missing PR label and included the test fixes in 22b22a5.

@MarvinSchenkel could this also be backported to 2.8.x?

@MarvinSchenkel
Copy link
Copy Markdown
Contributor

@marcelveldt could you sanity check this?

I remember you mentioned airplay forces us to send a volume level when the stream starts.

I think this could still result in volume jumps when the receiver uses a different scale. Did you test this with slipping tracks or just playing a different track when something is already playing?

@jyundt
Copy link
Copy Markdown
Author

jyundt commented May 25, 2026

I think this could still result in volume jumps when the receiver uses a different scale. Did you test this with slipping tracks or just playing a different track when something is already playing?

I reproduced this behavior by slipping (scrubbing?) through an actively playing track and manually advancing to the next track in the queue.

@MarvinSchenkel MarvinSchenkel dismissed their stale review May 25, 2026 16:44

Needs a sanity check first

@marcelveldt
Copy link
Copy Markdown
Member

Yes, AirPlay REQUIRES to send the volume, that is part of the protocol.
So you actually need to sync the volume from the parent player to AirPlay to prevent volume spikes, otherwise the volume will jump to the last known airplay volume.

I also notice that the volume differs on some devices, e.g. Sonos, so this most likely means that our scaling just is flawed and we need to fix that instead.

This PR is not the right fix as it will fix issue A but causes issue B instead.

@jyundt
Copy link
Copy Markdown
Author

jyundt commented May 26, 2026

Yes, AirPlay REQUIRES to send the volume, that is part of the protocol.
So you actually need to sync the volume from the parent player to AirPlay to prevent volume spikes, otherwise the volume will jump to the last known airplay volume.

I also notice that the volume differs on some devices, e.g. Sonos, so this most likely means that our scaling just is flawed and we need to fix that instead.

This PR is not the right fix as it will fix issue A but causes issue B instead.

Ah got it, thanks for the clarification. Lemme take another swing at this.

@MarvinSchenkel
Copy link
Copy Markdown
Contributor

Marking this PR as draft so we can keep track of which PRs needs our attention. Please mark as 'Ready for review' when you want us to have another look 🙏 .

@MarvinSchenkel MarvinSchenkel marked this pull request as draft May 26, 2026 09:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Sendspin/AirPlay track changes reset Yamaha MusicCast parent volume

4 participants